﻿using System;
using System.Collections.Generic;
using System.Text;
using Components;
using Model;

namespace ServiceHelper.Util
{
    public class Exec
    {
        public static Exec Create()
        {
            return new Exec();
        }

        private List<SqlApp> _list = new List<SqlApp>();

        public Exec AddSql(SqlApp app)
        {
            _list.Add(app);
            return this;
        }

        public Exec Clear()
        {
            _list = new List<SqlApp>();
            return this;
        }

        public string Do(bool throwException = true)
        {
            string msg = CommonManager.Entity.SaveData(_list);
            if (!string.IsNullOrEmpty(msg) && throwException)
                throw new StnException(msg);

            return msg;
        }
    }
}
